import {
  IsInt,
  IsString,
  IsBoolean,
  ValidateNested,
  IsOptional,
  IsNotEmpty,
  IsDate,
  IsNumber,
} from 'class-validator';
import { Type } from 'class-transformer';

class From {
  @IsInt()
  id: number;

  @IsBoolean()
  is_bot: boolean;

  @IsString()
  @IsNotEmpty()
  first_name: string;

  @IsString()
  @IsNotEmpty()
  username: string;

  @IsString()
  @IsNotEmpty()
  language_code: string;
}

class Chat {
  @IsInt()
  id: number;

  @IsString()
  @IsNotEmpty()
  title: string;

  @IsBoolean()
  is_forum: boolean;

  @IsString()
  @IsNotEmpty()
  type: string;
}

class ForumTopicCreated {
  @IsString()
  @IsNotEmpty()
  name: string;

  @IsInt()
  icon_color: number;

  @IsString()
  @IsNotEmpty()
  icon_custom_emoji_id: string;
}

class ReplyToMessage {
  @IsInt()
  message_id: number;

  @ValidateNested()
  @Type(() => From)
  from: From;

  @ValidateNested()
  @Type(() => Chat)
  chat: Chat;

  @IsNumber()
  date: number;

  @IsInt()
  message_thread_id: number;

  @ValidateNested()
  @Type(() => ForumTopicCreated)
  forum_topic_created: ForumTopicCreated;

  @IsBoolean()
  is_topic_message: boolean;
}

class Message {
  @IsInt()
  message_id: number;

  @ValidateNested()
  @Type(() => From)
  from: From;

  @ValidateNested()
  @Type(() => Chat)
  chat: Chat;

  @IsNumber()
  date: number;

  @IsInt()
  message_thread_id: number;

  @IsOptional()
  @ValidateNested()
  @Type(() => ReplyToMessage)
  reply_to_message?: ReplyToMessage;

  @IsString()
  @IsNotEmpty()
  text: string;

  @IsBoolean()
  is_topic_message: boolean;
}

export class Res {
  @IsNumber()
  update_id: number;
  message: Message;
}
